package com.ly.erms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.ly.erms.config.properties.ErmsProperties;

/**
 * Spring boot 方式启动类
 * 
 * @author liuyang
 * @date 2017年12月26日
 */
@SpringBootApplication
public class ErmsApplication extends WebMvcConfigurerAdapter {
	protected final static Logger logger = LoggerFactory.getLogger(ErmsApplication.class);

	@Autowired
	ErmsProperties ermsProperties;

	/**
	 * 增加swagger支持
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		if (ermsProperties.getSwaggerOpen()) {
			registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
			registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
		}
	}

	public static void main(String[] args) {
		SpringApplication.run(ErmsApplication.class, args);
		logger.info("ErmsApplication start success!");
	}
}
